﻿@using System.Text
@using OA.Model
@using OA.AspNetCore.Html
@using OA.Core.Model
@using OA.Core.Helper

@model PageList<SimpleKnowledge>
@{
    ViewBag.Title = "知识列表";
    Layout = "~/Areas/Member/Views/Shared/_Layout.cshtml";
}
<div class="layui-tab layui-tab-brief" lay-filter="user">
    <div class="layui-form layui-tab-content" id="LAY_ucm" style="padding: 5px 0;">
        <form action="" class="layui-form">
            <div class="layui-inline">
                <div class="layui-input-inline">
                    <input type="text" name="keyWord" placeholder="请输入知识名称搜索" class="layui-input" value="@ViewBag.Keyword">
                </div>
            </div>
            <div class="layui-inline">
                <button type="button" class="layui-btn searchButton">搜索</button>
                <a class="layui-btn" href="javascript:ShowPage('/Management/Knowledge/Create','添加知识')">添加知识</a>
            </div>
        </form>
    </div>
    <table class="layui-table" lay-data="{url:'GetData', cellMinWidth: 80, page: true,limit:15}" id="resultList" lay-filter="resultList">
        <thead>
            <tr>
                <th lay-data="{field:'ID', width:80, align:'center'}">ID</th>
                <th lay-data="{ field: 'Title'}">标题</th>
                <th lay-data="{field:'Name', width:160}">分组</th>
                <th lay-data="{field:'Author', width:120}">作者</th>
                <th lay-data="{width:80,field: 'IsTop'}">置顶</th>
                <th lay-data="{fixed: 'right', width:120, align:'center', toolbar: '#barDemo'}">操作</th>
            </tr>
        </thead>
    </table>
    <script type="text/html" id="barDemo">
        <a class="layui-btn layui-btn-primary layui-btn-xs" href="javascript:ShowPage('/Management/Knowledge/Edit?id={{d.ID}}','编辑知识')">编辑</a>
        <a class="layui-btn layui-btn-primary layui-btn-xs" href="javascript:DeleteItem({{d.ID}})">删除</a>

    </script>
     
</div>
<script type="text/javascript">
    function DeleteItem(id) {
        layer.confirm('您正在进行删除知识操作', {
            btn: ['是的,我要删除该知识', '不小心点错了'] //按钮
        }, function () {
            var url = "/Management/Knowledge/Delete?id=" + id;
            $.getJSON(url, function (data) {
                layer.msg(data.Msg);
                if (data.State === 200) {
                    $(".layui-laypage-btn")[0].click();
                }                 
            });
        }, function () {

        });
    }
</script>


